home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / postreap.wt4 < prev    next >
Text File  |  1996-05-14  |  881b  |  36 lines

  1. /*======================================================================
  2.     post_reap
  3.     
  4.     Manage exit status collection of a child spawned to handle posting
  5.  ====*/
  6.  
  7.  
  8.  
  9. #if    defined(BACKGROUND_POST) && defined(SIGCHLD)
  10. /*----------------------------------------------------------------------
  11.     Check to see if we have any posting processes to clean up after
  12.  
  13.   Args: none
  14.   Returns: any finished posting process reaped
  15.  ----*/
  16. post_reap()
  17. {
  18.     WaitType stat;
  19.     int         r;
  20.  
  21.     if(ps_global->post && ps_global->post->pid){
  22.     r = wait4(ps_global->post->pid, &stat, WNOHANG, NULL);
  23.     if(r == ps_global->post->pid){
  24.         ps_global->post->status = WIFEXITED(stat) ? WEXITSTATUS(stat) : -1;
  25.         ps_global->post->pid = 0;
  26.         return(1);
  27.     }
  28.     else if(r < 0 && errno != EINTR){ /* pid's become bogus?? */
  29.         fs_give((void **) &ps_global->post);
  30.     }
  31.     }
  32.  
  33.     return(0);
  34. }
  35. #endif
  36.